home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1797 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: gate.net!pslfl2-8
  2. From: bhutto@gate.net (William Hutto)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: ATTENTION C EXPERTS!! Extern Declarations - NEED HELP!
  5. Date: 16 Jan 1996 22:17:18 GMT
  6. Organization: CyberGate, Inc.
  7. Message-ID: <4dh85e$1b8u@news.gate.net>
  8. References: <4dcl71$94s@enterprise.sct.gu.edu.au> <4ddf0j$6mb@lyra.csx.cam.ac.uk>
  9. NNTP-Posting-Host: pslfl2-8.gate.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4ddf0j$6mb@lyra.csx.cam.ac.uk>,
  13.    93heb@eng.cam.ac.uk (H.E. Butterworth) wrote:
  14. >Hi,
  15. >
  16. >    IMHO
  17. >
  18. >    cdecl and near are compiler flags which tell the compiler to use the c 
  19. style
  20. >calling convention (as opposed to pascal style) and that the function is near 
  21. i.e.
  22. >not to reload the segment registers on function entry.  The macros _CDECL and
  23. >_NEAR just allow you to remove the flags by defining NO_KEYS.
  24. >
  25. >    I have seen these before only in code for the segmented x86 memory model 
  26. -
  27. >specifically in exported sections of 16 bit Windows DLLs where an exported
  28. >function must be declared far and cdecl - I think the compiler would 
  29. otherwise
  30. >use the pascal calling convention because it is slightly more efficient.  16 
  31. bit
  32. >Windows code has this stuff scattered all over it.
  33. >
  34. >    This may be a somewhat garbled version of 'The Truth' but I'm fairly sure
  35. >it's on the right lines.
  36. >
  37. >HB.
  38.  
  39. It is along the right lines. These keywords are generally used to override any 
  40. defaults. Because libraries of all kinds often times don't come with source 
  41. code, they can't be recompiled with a different calling convention. These 
  42. keywords are used with declarations in their (the libary's) header file(s) so 
  43. the compiler doesn't make the *default* assumption when linking or 
  44. binding which could produce *slightly* faulty code.
  45.  
  46. Bill
  47.  
  48. "Whatcha got on?...Your mind?"
  49.